package com.dr.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dr.domain.ConstantType;
import com.dr.domain.PageResult;
import com.dr.mapper.ConstantTypeMapper;
import com.dr.service.ConstantTypeService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: yangjianfeng
 * @Date: 2025/07/03 10:03
 * @Description:
 */
//1 做面试题   2 面试 Spring AOP
    //包含单表的增删改查
@Service
public class ConstantTypeServiceImpl extends ServiceImpl<ConstantTypeMapper,ConstantType> implements ConstantTypeService {

    @Autowired
    private ConstantTypeMapper constantTypeMapper;

    @Override
    public PageResult<ConstantType> page(Integer pageNum, Integer pageSize, String condition) {
        //开启分页
        PageHelper.startPage(pageNum,pageSize);
        List<ConstantType> list= constantTypeMapper.selectDataByCondition(condition);
        Page<ConstantType> page=(Page)list;

        PageResult<ConstantType> pageResult = new PageResult<>();
        pageResult.setTatal(page.getTotal());
        pageResult.setData(page.getResult());
        return pageResult;
    }

    @Override
    public void add(ConstantType constantType) {
        constantTypeMapper.insert(constantType);
    }
}
